// 同类型
function getkind(){
    $.get("../php/phpe/getGoodsListNew.php?typeId=006&count=8",function(data){
        let goodlist = JSON.parse(data);
        console.log(goodlist);
        let htmlSrc = ''
        goodlist.forEach(goods=>{
            htmlSrc+=`
            <li class="recommend-item">
                <div class="break">
                    <img src="../${goods.goodsImg}">
                    <div class="recom-name">${goods.goodsName}</div>
                    <div class="recom-price">${goods.goodsPrice}元</div>
                    <div class="recom-tops">68.6万人好评</div>
                </div>
                <div class="recom-action">
                    <a href="#" class="ben-small" onclick="location.href = 'xiangqin.html?goodsId=${goods.goodsId}'">
                        加入购物车
                    </a>
                </div>
                <div class="recom-notiae">
                    <a href="#" class="btn-block">成功加入购物车</a>
                </div>
            </li>
            `
        })
        $('.recommend-list').html(htmlSrc)
    })
}
$(function(){
    getkind()
    yangshi()
})
// 导航栏选项卡

$('.bar').hover(function(){
    $(this).css('color','#ff6700');
    $('.bar-xuan').eq($(this).index()).css({
        'display':'block'
    })
},function(){
    $(this).css('color','')
    $('.bar-xuan').eq($(this).index()).css({
        'display':'none'
    })
})
$('.control').hover(function(){
    $('.bar-xuan').eq($(this).index()).css({
        'display':'none'
    })
})
// 轮播图上的nav的选项卡
$('.category_item').hover(function(){
    $(this).css('background','#ff6700')
    $('.item-div').eq($(this).index()).css({
        'visibility':'visible'
    })
    $('.view').css({
        display:'none'
    })
},function(){
    $(this).css('background','')
    $('.item-div').eq($(this).index()).css({
        'visibility':'hidden'
    })
    $('.view').css({
        display:'block'
    })
})

// 跳转到首页
$('.J-goblck').on('click',function(){
    location.href = 'xiaomi.html'
})


// function yangshi(){
//     let goodsId = location.search.split('=')[1];
//     $.get("../php/phpe/getGoodsInfo.php?goodsId="+goodsId,function(data){
//         let goods = JSON.parse(data);   
//         let htmlSrc = `
//             <span class="name">${goods.goodsName}</span>
//         `
//         $('.goods-yangshi').html(htmlSrc)
//     })

// }

// 跳转到购物车
$('.btn-primty').on('click',function(){
    location.href = 'shopping.html'
})












